<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2016/9/22
 * Time: 9:47
 *订单管理
 */

require('../include/init.inc.php');
$method = $kd_name = $kd_website = $order_sn = $kd_sn = $fah = '';
extract($_REQUEST, EXTR_IF_EXISTS);

if (Common::isPost()) {
    Common::checkParam($order_sn);
    $Order = AdminOrder::getByOrderSn($order_sn);
    if (empty($Order)) {
        Common::exitWithError(ErrorMessage::ORDER_NOT_EXIST, "one_page_shop/kuaidi_edit.php");
    }

    $kd = AdminKd::getKdInfoBySn($order_sn);
    if ($kd) {
        $update_data = array("kd_name" => $kd_name, "kd_url" => $kd_website, "kd_sn" => $kd_sn, "isGo" => $fah, "modifytime" => time());
        $result = AdminKd::update($order_sn, $update_data);
    } else {
        $data = array("kd_name" => $kd_name, "kd_url" => $kd_website, "kd_sn" => $kd_sn, "order_sn" => $order_sn, "isGo" => $fah, "createtime" => time(), "modifytime" => time());
        $result = AdminKd::add($data);
    }

    if ($result) {
        SysLog::addLog(UserSession::getUserName(), 'Add', 'KuaidiEdit', $order_sn, json_encode($data));
        Common::exitWithSuccess('修改完成', 'one_page_shop/kuaidi_edit.php');
    } else {
        OSAdmin::alert("error");
    }
}

$confirm_html = OSAdmin::renderJsConfirm("icon-remove");
Template::assign('osadmin_action_confirm', $confirm_html);
Template::display('one_page_shop/kuaidi.tpl');